﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Assignment
{
    public partial class Assignment1 : Form
    {
        public Assignment1()
        {
            InitializeComponent();
        }

        private void Assignment1_Load(object sender, EventArgs e)
        {
            dateComeText.Text = DateTime.Today.ToShortDateString();
            genderCombo.SelectedIndex = 0;
            shortTimeRadio.Checked = true;
            practiceRadio.Checked = true;
        }

        private void Assignment1_Shown(object sender, EventArgs e)
        {
            fullNameText.Focus();
        }

        private void closeButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            StringBuilder messageString = new StringBuilder();

            messageString.AppendLine("Ngày vào làm : " + dateComeText.Text);
            messageString.AppendLine("Họ tên : " + fullNameText.Text);
            messageString.AppendLine("Ngày sinh : " + birthdayMaskedText.Text);
            messageString.AppendLine("Giới tính : " + genderCombo.SelectedItem.ToString());
            messageString.AppendLine("Công việc : "
                                     + (devCheck.Checked ? devCheck.Text : "")
                                     + (deployCheck.Checked ? deployCheck.Text : "")
                                     + (managerCheck.Checked ? managerCheck.Text : "")
                                     + (customerCheck.Checked ? customerCheck.Text : ""));

            messageString.AppendLine("Hình thức : "
                                     + (shortTimeRadio.Checked ? shortTimeRadio.Text : "")
                                     + (parttimeRadio.Checked ? parttimeRadio.Text : "")
                                     + (fullTimeRadio.Checked ? fullTimeRadio.Text : ""));

            messageString.AppendLine("Tình trạng : "
                                     + (practiceRadio.Checked ? practiceRadio.Text : "")
                                     + (probationaryRadio.Checked ? probationaryRadio.Text : "")
                                     + (permanentRadio.Checked ? permanentRadio.Text : ""));

            logText.Text = messageString.ToString();
        }

        private void Assignment1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("Bạn muốn đóng cửa sổ?", "Thông tin nhân viên", MessageBoxButtons.YesNo,
                                       MessageBoxIcon.Information) == DialogResult.No)
                e.Cancel = true;
        }

        private void fullNameText_Leave(object sender, EventArgs e)
        {
            if (fullNameText.Text.Length <= 0)
            {
                logText.Text = "Hãy điền họ tên";
                fullNameText.Focus();
            }
        }
    }
}
